global using WXWorkSvc.Private;

using WXWorkSvc.Common.Extensions;
using WXWorkSvc.Common.Models;
using WXWorkSvc.Models;


namespace WXWorkSvc;

public class Program
{
    public static void Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);
        #region Add services to the container.



        builder.Services.AddAuthorization();

        builder.Services.AddRazorPages(o =>
        {
            o.Conventions.AuthorizeAreaFolder("Admin", "/Agent");
            o.Conventions.AuthorizeAreaFolder("Admin", "/Corp");
            o.Conventions.AuthorizeAreaFolder("Admin", "/PrivateAgent");
            o.Conventions.AuthorizeAreaFolder("Admin", "/Suite");
        });
        var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");

        builder.Logging.AddSqlServerLogger();
        builder.Services.AddWXWorkPrivate<ERole>(connectionString);

        builder.Services.AddSingleton<WXWork3rd>();
        builder.Services.AddSingleton<WXWorkPrivate>();
        builder.Services.AddSingleton<Cryptography>();
        //builder.Services.AddSingleton<IRole, RoleBase<ERole>>();
        #endregion

        var app = builder.Build();
        app.UseWXWorkPrivate();
        app.Run();
    }
}
